package org.x.usermod.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.x.commonmod.config.Result;
import org.x.commonmod.enums.LogAsync;
import org.x.usermod.dto.AssignAclsDTO;
import org.x.usermod.dto.AssignRolesDTO;
import org.x.usermod.dto.UserAclDTO;
import org.x.usermod.service.IAuthManagementService;

@RestController
@RequestMapping("/api/auth")
public class AuthManagementController {
    @Autowired
    private IAuthManagementService authManagementService;

    //用户角色分配
    @LogAsync("用户角色分配")
    @PostMapping("/assignRoles")
    public Result assignRole(@RequestBody AssignRolesDTO assignRolesDTO) {
        return authManagementService.assignRole(assignRolesDTO);
    }
    //权限分配
    @LogAsync("权限分配")
    @PostMapping("/assignAcls")
    public Result assignAcl(@RequestBody AssignAclsDTO assignAclsDTO) {
        return authManagementService.assignAcl(assignAclsDTO);
    }
    //数据权限配置
    //@TOOD缺表
//    @PostMapping("/dataScope")
//    public Result dataScope(@RequestBody AssignDataScopeDTO assignDataScopeDTO) {
//        return authManagementService.assignDataScope(assignDataScopeDTO);
//    }
    //用户权限查询
    @GetMapping("/userPermissions")
    public UserAclDTO userPermissions(@RequestParam Long userId) {
        UserAclDTO userAclDTO = authManagementService.userPermissions(userId);
        return userAclDTO;
    }
}
